package Demo1.a02demo2;

import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入一段字符串");
            String s = sc.nextLine();
            String regex = "[1-9]\\d{0,9}";
            if (!s.matches(regex)) {
                System.out.println("数据格式有误");
            } else {
                System.out.println("是一个整数");
                int num = Integer.parseInt(s);
                System.out.println(num);
                break;
            }
        }
    }
}
